﻿// Write a method that returns the index of the first element in array that is bigger than its neighbors, 
// or -1, if there’s no such element. Use the method from the previous exercise.

using System;

class GetFirstBiggerThanNeighborsElementIndex
{
    static void Main()
    {
        int[] intArray = { 1, 1, 0, 1, 2, 3, 99, -5, 0 };
        int index = GetFirstBiggerThanNeighborsPos(intArray);
        if (index != -1)
        {
            Console.WriteLine("The first bigger number than its neighbors is {0}", intArray[index]);
        }
        else
        {
            Console.WriteLine("No such element");
        }
    }

    private static int GetFirstBiggerThanNeighborsPos(int[] intArray)
    {
        for (int i = 0; i < intArray.Length; i++)
        {
            if (BiggerNeighbors.IsBiggerThanNeighbors(i, intArray))
            {
                return i;
            }
        }

        return -1;
    }
}